package com.example.verifysdk;

import java.io.IOException;

/**
 * Created by Liuv on 2017/5/12.
 */

public class ResponseException extends Exception {

    private int code = -1;

    public ResponseException() {
        super();
    }

    public ResponseException(String message) {
        super(message);
    }

    public ResponseException(String message, Throwable cause) {
        super(message, cause);
    }

    public ResponseException(String message, int code){
        super(message);
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public ResponseException(IOException e){
        super(e.getMessage(), e.getCause());
    }

    public ResponseException(BaseJson baseJson){
        super(baseJson == null ? "Unknow error" : baseJson.getError());
        code = (baseJson == null ? 0 : baseJson.getCode());
    }

    @Override
    public String toString() {
        return "ResponseException{" +
                "code=" + code +
                ",message=" + getMessage() +
                '}';
    }
}
